import tensorflow as tf
from skimage import io,util
import numpy as np

def test_tf_ops():
    """
    a = tf.constant(value=tf.random_normal(shape=[3,3],stddev=0.35))
    b = tf.constant(value=tf.random_uniform(shape=[3,3]))
    """
    c = tf.constant([[1.0, 2.0], [3.0, 4.0]])
    d = tf.constant([[1.0, 1.0], [0.0, 1.0]])
    e = tf.matmul(c,d)
    f = tf.reduce_sum(input_tensor=e,reduction_indices=0)
    sess = tf.Session()
    result = sess.run(f)
    #init_op = tf.initialize_all_variables()
    print c
    print d
    print e
    print result
    print tf.shape(c)

def test_img_as_ubyte():
    img_path = '/media/dell/cb552bf1-c649-4cca-8aca-3c24afca817b/dell/wxm/Data/decsai/GM512/patches18_val/2_sar-large.pgm'
    img_arr = io.imread(img_path)
    print img_arr
    img_arr_noised = util.random_noise(img_arr)
    print img_arr_noised * 255
    img_arr_noised_u = util.img_as_ubyte(np.asarray(img_arr_noised * 255,dtype=np.uint8))
    print img_arr_noised_u

def test_skimage_crop():
    img_path = '/media/dell/cb552bf1-c649-4cca-8aca-3c24afca817b/dell/wxm/Data/decsai/GM512/inf/Bird.pgm'
    img_arr = io.imread(img_path)
    print img_arr.shape
    io.imshow(img_arr)
    io.show()
    img_arr_cropped = util.crop(img_arr,126)
    print img_arr_cropped.shape
    io.imshow(img_arr_cropped)
    io.show()


if __name__ == '__main__':
    test_skimage_crop()
